﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <style>
        .t {
            border: 1px solid #C3CED9;
            border-radius: 5px 5px 5px 5px;
            font-size: 14px;
            line-height: 25px;
            margin-right: 10px;
            padding: 0;
        }

        .item {
            margin-top: 5px;
            margin-left: 5px;
            margin-bottom: 5px;
        }

        .container {
            margin-top: 5px;
            width: 171px;
        }
    </style>
    <link href="../Resource/Css/jquery-ui-1.10.4.custom.min.css" rel="stylesheet" />
    <script src="Resource/jquery-1.10.2.js"></script>
    <script src="../Resource/Jquery/jquery-ui-1.10.4.custom.min.js"></script>
    <script src="../Resource/Jquery/jquery.ui.datepicker-zh-CN.js"></script>
    <script src="Resource/Core.js"></script>
    <script src="Resource/TextBoxComponent.js"></script>
</head>
<body>
    <input type="search" />
    <input type="text" id="txt1" />
    <input type="text" id="txt2" value="文本框2" />

    <table>
        <tr>
            <td>
                <input type="text" tag="t" value="验证数字" /></td>
            <td colspan="2">
                <input type="text" tag="txt5" value="文本框1" /></td>
        </tr>
        <tr>
            <td>
                <input type="text" id="txt_date" value="时间控件" /></td>
            <td>
                <input type="text" id="txt6" tag="t" value="数字" /></td>

            <td>
                <input type="text" id="Text1" tag="t" value="" />
                <input type="text" id="Text2" tag="t" value="" placeholder="这个属性不错" />
            </td>
        </tr>
        <tr>
            <td>
                <input type="text" id="Text3" value="tooltip_show" />
            </td>
            <td>
                <input type="text" id="Text4" value="tooltip_hidden" />
            </td>
            <td>
                <input type="button" value="点我马上隐藏tooltip" id="btn2" />
            </td>
        </tr>
    </table>

    <input type="button" id="btn1" value="去除圆角样式" /><br />

    <div>
        <h4>auto complete 测试: as below</h4>
    </div>
    <div style="border: 1px dashed red;">
        <input type="text" id="txt_auto" />

        <input type="text" id="txt_auto1" />


        <input type="text" id="iq_aotu" />
    </div>
</body>
</html>
<script type="text/javascript">
    var auto_Complete = function (option) {

    }

    //$("#txt1").radius().description("请输入姓名").isNumber("ssss", 200);
    $("input[type=text][tag=t]").radius();

    $("#btn1").click(function () {
        $("#txt1").removeRadius();
    })

    $("#Text1").radius().description("请输入搜索条件").isNumber("ssss", 100);

    $("#txt6").isNumber("输入错误", 100);

    $("#txt_date").datepicker({
        onSelect: function (a, b) {
            $(this).focus();
        },
        dateFormat: "mm/dd/yy"
    });

    //$("#Text3").tooltip("1", 100);
    $("#Text4").tooltip("我是测试用的tooltip2", 100);
    $("#btn2").click(function () {
        $("#Text4").hidTooltip();
    })

    var _d = "[";
    for (var i = 0; i < 99; i++) {
        if (i % 3 == 0) {
            _d += "{Id:'" + i + "',Name:'name_" + i + "'},";
        }
        else if (i % 4 == 0) {
            _d += "{Id:'" + i + "',Name:'age_" + i + "'},";
        }
        else if (i % 5 == 0) {
            _d += "{Id:'" + i + "',Name:'address_" + i + "'},";
        }
    }
    _d = _d.substring(0, _d.length - 1);
    _d += "]";

    function getId() {
        var arg = arguments[0];
        window.console.log("点击的id:" + arg.id);
    }

    $("#iq_aotu").auto_Complete({
        data: eval("(" + _d + ")"),
        idFiled: "Id",
        textFiled: "Name",
        afterClick: getId,
        size: 8
        //itemClass: "item",
        //containerClass: "container"
    });

    $("#txt_auto").auto_Complete({
        data: eval("(" + _d + ")"),
        idFiled: "Id",
        textFiled: "Name",
        afterClick: getId,
        size: 6
    });

    $("#txt_auto1").auto_Complete({
        data: eval("(" + _d + ")"),
        idFiled: "Id",
        textFiled: "Name",
        afterClick: getId,
        size: 5
    });

    var eventManager = function () {

        this.listeners = {};

        this.doEvent = function (eventName, eventProperties) {
            if (!this.listeners[eventName]) {
                return;
            }
            if (this.listeners[eventName].length == 0) {
                console.log("事件:[" + eventName + "]已经没有函数指针了,请重新添加一个指针来执行");
                return;
            }
            for (var i = 0; i < this.listeners[eventName].length; i++) {
                this.listeners[eventName][i](eventProperties);
            }
        }

        this.addListener = function (eventName, callback) {
            if (this.listeners[eventName] == undefined) {
                this.listeners[eventName] = [];
            }

            this.listeners[eventName].push(callback);
        }

        this.removeListener = function (eventName, callback) {
            if (!this.listeners[eventName]) {
                return;
            }
            for (var i = 0; i < this.listeners[eventName].length; i++) {
                if (this.listeners[eventName][i] == callback) {
                    var index = this.listeners[eventName].findItem(callback);
                    this.listeners[eventName] = this.listeners[eventName].deleteItem(index);
                    return;
                }
            }
        }
    }

    function f1() {
        console.log(arguments[0] + "-----0");
    }
    function f2() {
        console.log(arguments[0] + "-----1");
    }

    var e = new eventManager();
    e.addListener("testEvent", f1);

    e.addListener("testEvent", f2);

    e.doEvent("testEvent", { name: 1 });

    e.removeListener("testEvent", f1);
    e.doEvent("testEvent", { name: 2 });
    e.removeListener("testEvent", f2);
    e.doEvent("testEvent", { name: 3 });
</script>
